package com.pstreets.lwuit.demo.widgets;


import com.sun.lwuit.Calendar;
import com.sun.lwuit.Command;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.animations.CommonTransitions;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.plaf.UIManager;
import com.sun.lwuit.util.Log;
import com.sun.lwuit.util.Resources;
import javax.microedition.midlet.MIDlet;

/**
 * @author james
 */
public class CalendarDemo extends MIDlet implements ActionListener {

    Calendar cal;
    
    public void startApp() {
        
        //init the LWUIT display
        Display.init(this);
        
        //setting the application theme
        try{
            Resources r=Resources.open("/LWUITtheme.res");
            UIManager.getInstance()
                    .setThemeProps(r.getTheme
                    (r.getThemeResourceNames()[0]));
        }catch (Exception e){}
        
        
        Form mainForm = new Form("Calendar  Demo");
        
        mainForm.setLayout(new BorderLayout());
        
        cal=new Calendar();
        cal.addActionListener(this);
       
        mainForm.addComponent(BorderLayout.CENTER, cal);
       
        mainForm.setTransitionOutAnimator(CommonTransitions.createFade(400));
        
        mainForm.addCommand(new Command("Left soft key", 2));
        mainForm.addCommand(new Command("Right Soft key", 2));
        
        mainForm.show();
        
    
    }
    
    public void pauseApp() {
    }
    
    public void destroyApp(boolean unconditional) {
    }


    public void actionPerformed(ActionEvent ae) {
         Log.p(cal.getDate().toString());
    }
}
